﻿namespace C12_Ex02_Shaked_032675316_Itay_032511057
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    public static class DictionaryExtender
    {
        public static Dictionary<T1, List<T2>> GetComplement<T1, T2>(this Dictionary<T1, List<T2>> i_This, Dictionary<T1, List<T2>> i_Other)
        {
            Dictionary<T1, List<T2>> dictionary = new Dictionary<T1, List<T2>>();
            foreach (T1 key in i_Other.Keys)
            {
                if (i_This.ContainsKey(key))
                {
                    List<T2> exclusiveItems = i_Other[key].Except(i_This[key]).ToList();
                    if (exclusiveItems.Count > 0)
                    {
                        dictionary[key] = exclusiveItems;
                    }
                }
                else
                {
                    dictionary[key] = i_Other[key];
                }
            }

            return dictionary;
        }
    }
}
